/* eslint-disable camelcase */
// 补0函数
export function addZero(s) {
  return s < 10 ? `0${s}` : s;
}
// 音乐时长格式化
export function format(my_time) {
  if (!my_time) {
    return '';
  }
  const days = my_time / 1000 / 60 / 60 / 24;
  const daysRound = Math.floor(days);
  const hours = my_time / 1000 / 60 / 60 - (24 * daysRound);
  const hoursRound = Math.floor(hours);
  const minutes = my_time / 1000 / 60 - (24 * 60 * daysRound) - (60 * hoursRound);
  const minutesRound = Math.floor(minutes);
  const seconds = Math.round(my_time / 1000 - (24 * 60 * 60 * daysRound)
    - (60 * 60 * hoursRound) - (60 * minutesRound));
  const time = `${minutesRound}:${addZero(seconds)}`;
  return time;
}
// 判断 string 类型
export function isString(v) {
  return typeof v === 'string';
}

// http 链接转化成 https
export function toHttps(url) {
  if (!isString(url)) {
    return url;
  }
  return url.replace('http://', 'https://');
}
